home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Prograph Classic 2.6.1 / Prograph Tutorial Manual / Prograph Tutorial / Prograph Tutorial.rsrc / TEXT_138.txt < prev    next >
Encoding:
Text File  |  1995-10-16  |  8.8 KB  |  212 lines

  1. t    Adding a Window
  2.  
  3. *26*The Folks Database is beginning to behave like a Macintosh application. But it needs a window to provide a means of interaction between the user and the application.
  4.  
  5. u    Select*296* Edit Application from the Exec menu.
  6.  
  7. u    Select the Windows radio button if it is not already selected. Select the Active List radio button.
  8.  
  9. u    Double-click the Window item in the Classes scrolling list to create a new Window class object. Creation of this object is confirmed with the Untitled entry in the List of Instances.
  10.  
  11. u    Click on the Untitled entry to select it and the List of Instances Scroll List, and then click on the*120* Edit button.
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. A small blank default window appears over the*42* Application editor*41* dialog. You turn this featureless window into a window that fits the design of your application by using Prograph‚Äôs*306* *1163*Window and*310* Window Item *1168* editors.
  32.  
  33. For your Folks Database application, the initial goal is to have a window that allows users to give a name to each new Person object they create. Your application window needs an editable text field where the name can be typed. The window also needs a simple button that, when pushed, creates and names a new Person object. 
  34.  
  35. Macintosh*122* button names usually suggest button function to users. This Folks Database application will keep track of a pool of people, and include each new Person object in the growing pool. So the button you later create can be an Add button.
  36.  
  37. Now that you have a good idea of what to put in this generic window instance to change it into your Folks Database application window, do the following:
  38.  
  39. u    Option-command-double-click anywhere within the window (except on its title bar). The Window editor pops up. Note that a default /Close method name has already been provided in the Close Method field.
  40.  
  41. u    Type Folks Database in the Window Title edit field, replacing the highlighted Untitled.
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. ___________________________________________________________
  57. NOTE: For now, you don‚Äôt need to worry about specifying Activate, Idle*717*, and Key *718*methods. The Activate *715*method is called when the window is brought to the top of a stack of windows. The Idle method is called when there is nothing else to do (that is, when no other events are being processed). The Key method is called when the user presses a key.
  58.  
  59. Also, for now accept the default document window-type radio button and the checked boxes selecting Close Box and Grow Box on this document window. If you do experiment with *1183*window types and attribute check boxes, use a Option-Command-double-click combination in the generic window to pop up the Window editor. You need to set your application window back to a document window with Close Box and Grow Box, to be consistent with the rest of the Grand Tour.
  60. -----------------------------------------------------------
  61.  
  62. u    Press the OK button or press Return to dismiss the*1164**307* Window editor.
  63.  
  64. The window is now appropriately titled and ready for you to add the editable text field for entering new Person names wherever you want it located.
  65.  
  66. u    Position the crosshair cursor in the upper left corner of the Folks Database window. Command-drag a rectangular marquee about half an inch by two inches in size. Notice that a grabbing-hand cursor appears while you drag. Release the mouse button when the marquee looks about like this:
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. When you release the mouse button, the area within the marquee aligns to an invisible grid in the window. The bottom and right edges of the box are highlighted with thick solid lines, and a small square grow box is in the lower right corner. This rectangle is an unspecified Window Item instance. 
  87.  
  88. ===========================================================
  89. TIP: The Window editor maintains an invisible, eight-pixel grid for aligning objects in a window. You can override this default alignment by holding down the Option key while dragging the marquee.
  90. ===========================================================
  91.  
  92. Currently this box behaves much like a rectangle in a typical Macintosh graphics program. That is, it is an independent, resizable object. You can click-drag the lower right corner of this object to resize it.
  93.  
  94. Unlike a graphics-program object, however, this object can be easily transformed into one of the various types of objects that populate a Macintosh interface. It can become an edit-text field, a set of radio buttons, a scrolling list, a push button, an icon, a graphic, or a check box, among other interface objects. To turn this Window Item into an*290* Edit Text field:
  95.  
  96. u Double-click this new Window Item box to pop up the Window Item editor*299**1169*. This editor consists of a scrolling list of selections, which are the types of objects into which the Window Item instance can be turned.
  97.  
  98. ___________________________________________________________
  99. NOTE: The list in the*311* Window Item editor consists of the names of all the subclasses of the Window Item class in the System class hierarchy in the Classes window.
  100. -----------------------------------------------------------
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. u    Click the Edit Text entry in the scrolling list.
  113.  
  114. u    Press the OK button or press Return. The Window Item editor dialog disappears, and the Edit Text editor pops up.
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. u    Type Name in the Name field.
  134.  
  135. u    Scroll the font list and click the Geneva item (or something similar to this)
  136.  
  137. u    Type 18 (or something else appropriate) in the Size box.
  138.  
  139. u    Click the Bold check box and accept the other instance attribute default values by pressing the OK button or by pressing Return.
  140.  
  141. The Edit Text editor disappears. The Edit Text item still looks a bit unusual because it is selected and the window is in edit mode. As soon as you begin to work on the Add button, the Edit Text item will take on its more familiar black box outline look.
  142.  
  143. u    Slightly below the Edit Text item, Command-drag a marquee about the size of the typical OK or Cancel button.
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. u    Double-click on this new Window Item object to pop up the Window Item editor.
  159.  
  160. u    Press OK or Return to accept the *263*default selection,*298* Button, in the editor‚Äôs scrolling list. The Window Item editor is replaced by the Button editor*121*.
  161.  
  162. u    Type Add in the Button Name field and press Tab.
  163.  
  164. u    Type Person/Add in the*166* Click Method field.
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. u    Press the OK button or press Return.
  176.  
  177. ___________________________________________________________
  178. NOTE: Window Items are added to the item list of a Window in the order in which they are created. If you want to make a particular button the default button (so that pressing Return is equivalent to clicking on the button), you must make the button the first item in the list. You can do this by*118* creating the default button first, or you can select the button and repeatedly choose*113**277* Bring Closer *595*from the Edit menu until the system beep tells you that the item has been brought to the front of the list. 
  179. -----------------------------------------------------------
  180.  
  181. The*167* click method is the method that executes when the button is pressed. The default class of Window Item *1060**1173*is the Window class*1180* (similar to the default class of Menu Item being the Menu class). If you used a *232*data-determined *700*method reference, /Add, for the button‚Äôs click method, the Add method would need to be created in the Window *1057*class. Since Add creates a Person object, the explicit Person/Add specification is used to promote application-design clarity.
  182.  
  183. The design objective for the Add button is to have a click on it initiate the creation of a Person object. Further, its name attribute is to be set to the text string typed into the Edit Text field in the Folks Database window. To meet this initial objective, your Folks Database window now looks like this:
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198. To see your Folks Database application in action, leave Application Builder and start your application running.
  199.  
  200. u    Click the close box of the Folks Database window.
  201.  
  202. u    Press Return to dismiss the Application editor.
  203.  
  204. u    Select Run initial in the Exec menu or press Command-R to start Folks Database running.
  205.  
  206. ___________________________________________________________
  207. NOTE: When you go to the Application editor, the application deactivates. You then have to do a Run initial from the Exec menu to resume execution.
  208.  
  209. If the window you just created does not appear along with your File menu, switch context and select Edit Application from the Exec menu to pull up the Application editor. Make sure that the Folks Database window is visible in the List of Instances scrolling list when you click the Active List radio button. If it is not, click the Library radio button, select the Folks Database item in the List of Instances and then click the Add to Active List button. You should now see your window when you again switch context.
  210. -----------------------------------------------------------
  211.  
  212.